import Vue from 'vue'
import Vuex from 'vuex'
import User from './user.js'
import axios from 'axios'
Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    flag: true
  },
  getters: {
  },
  mutations: {
    change (state) {
      state.flag = !state.flag
    }
  },
  actions: {
    async initUserInfo (context) {
      // console.log(context.state.User.token)
      const { data: res } = await axios.get('/my/userinfo')
      context.commit('User/updateUserInfo', res.data)
    }
  },
  modules: {
    User
  }
})
export default store
